'use strict';

/* Filters */
var fulboFilters = angular.module('fulboFilters', []);

fulboFilters.filter('checkmark', function() {
  return function(input) {
    return input ? '\u2713' : '\u2718';
  };
});

fulboFilters.filter('dateFormat', function() {
	  return function(input, formatString) {
		  return moment(input).locale('es').format(formatString);
	  };
});
fulboFilters.filter('orderObjectBy', function(){
	return function(input, attribute) {
		if (!angular.isObject(input)) return input;

	    var array = [];
	    for(var objectKey in input) {
	        array.push(input[objectKey]);
	    }

	    array.sort(function(a, b){
	        a = parseInt(a[attribute]);
	        b = parseInt(b[attribute]);
	        return a - b;
	    });
	    return array;
	};
});
